package org.leiyang.controller;

import org.leiyang.common.dtos.TestRequestVO;
import org.leiyang.service.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/test")
public class TestController {
    private static final Logger log = LoggerFactory.getLogger(TestController.class);
    private final TestService testService;

    public TestController(TestService testService) {
        this.testService = testService;
    }

    @GetMapping("/one/info")
    String showOneInfo(String info){
        log.info("开始调用syncShowOneInfo方法");
        return testService.showOneInfo(info);
    }

    @GetMapping("/sync/one/info")
    Mono<String> syncShowOneInfo(String info){
        log.info("开始调用syncShowOneInfo方法");
        return testService.syncShowOneInfo(info);
    }

    @PostMapping("/names")
    Flux<String> listNames(@RequestBody TestRequestVO requestVO) {
        log.info("开始调用listNames方法");
        return testService.listNames(requestVO);
    }
}
